<template>
  <div class="my-tag">
    <input
      v-if="isShow"
      v-focus
      @blur="isShow = false "
      class="input"
      type="text"
      placeholder="输入标签"
      :value='value'
      @keyup.enter="changeTag"
    />
    <div class="text" v-else @dblclick="check">{{value}}</div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isShow: false,
    };
  },
  props: {
    value:String
  },
  methods: {
    check() {
      this.isShow = true;
    },
    changeTag(e){
      this.$emit('input',e.target.value);
      this.isShow = false;
    }
  },
};
</script>

<style lang='less' scoped>
.my-tag {
  cursor: pointer;
  .input {
    appearance: none;
    outline: none;
    border: 1px solid #ccc;
    width: 100px;
    height: 40px;
    box-sizing: border-box;
    padding: 10px;
    color: #666;
    &::placeholder {
      color: #666;
    }
  }
}
</style>